function request(url, params = {}, type = "get") {
    return new Promise(function (resolve, reject) {
        $.ajax({
            type: type,
            url: url,
            data: {
                ...params
            },
            dataType: "json",
            success: function (result) {
                resolve(result);  // 如果请求成功, 传递请求的数据
            }
        })
    })
}

// 注册
const isExistUser = params => request("../php/isExistUser.php", params, "post");
const isExistPhone = params => request("../php/isExistPhone.php", params, "post");
const isExistEmail = params => request("../php/isExistEmail.php", params, "post");
const register = params => request("../php/register.php", params, "post");

// 登录
const login = params => request("../php/isLogin.php", params, "post");

// 主页面
const searchOrderLimit = params => request("../php/searchOrderLimit.php", params);
const deleteGradeById = params => request("../php/delete.php", params, "post");
const searchGradeById = params => request("../php/searchGradeById.php", params);
const updateGradeById = params => request("../php/updateGradeById.php", params, "post");

// const addToShoppingCar = params => request("../php/addToShoppingCar.php", params, "post");

// 商品列表
const searchAllGoods = params => request("../php/searchAllGoods.php", params);
const searchGoodsById = params => request("../php/searchGoodsById.php", params);

const addShoppingCar = params => request("../php/addShoppingCar.php", params, "post");

// 购物车
const searchShoppingByUser = params => request("../php/searchShoppingByUser.php", params, "post");
const deleteShoppingCarById = params => request("../php/deleteShoppingCarById.php", params);
const addNum = params => request("../php/addNum.php", params, "post");
const reduceNum = params => request("../php/reduceNum.php", params, "post");
const shoppingNum = params => request("../php/shoppingNum.php", params, "post");